package com.mxm.java1;

import java.io.FileNotFoundException;

public class CustomClassLoader extends ClassLoader{
    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        try {
            byte[] result=getClassFromCustomPath();
        if(result==null){
                throw new FileNotFoundException();
        }else{
            return defineClass(name,result,0,result.length);

        }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return super.findClass(name);
    }

    private byte[] getClassFromCustomPath() {
        //如果指定的字节码文件进行了加密，则需在此方法中进行揭秘操作
        return new byte[202];
    }
}
